1. Field of the Invention
Embodiments described herein are directed to a system for managing energy usage of processors while executing protocol state machines. Specifically, an alternate method of implementing protocol state machines that conserves energy on energy conscious devices is described.
2. Related Art
Protocol state machines typically represent communication protocol implementations. The actual implementation creates an instance of the state machine in a programming language such as assembler or C, for example. In addition, a protocol may involve communication between two entities such as two ends of a transport-level connection or two application level processes. In such a case, there must be multiple instances of the protocol state machine instantiated to handle separately the state and traffic involving each pair of separate entities engaged in the protocol-based communication.
Each such instance represents a separate and independent context and may have resources such as buffers, timers, etc. When a packet for the protocol is received, the context for the packet is identified; the corresponding instance of the protocol state machine is invoked; the instance executes the relevant part of the protocol state machine and returns to a dormant state until invoked again. On the transmission end, a separate instance of the protocol state machine handles each context. When invoked, the protocol state machine handles transmission of packets by performing necessary actions such as buffer management, setting a timer if the transmission needs to be scheduled for a later time, and invoking the underlying protocol layer or physical hardware to complete the transmission. The transmit portion of the protocol may become dormant again.
Many parts of the protocol state machine require use of resources such as CPU cycles, memory, and timers. For instance, CPU cycles are necessary for execution of protocol state machine code or associated actions. Memory is needed for copying buffers and adding or modifying headers to packets. A timer may be set to schedule a transmission or retransmission, meter incoming traffic, or detect communication problems.
Typically, communication architectures are layered in two or more layers with a separate protocol handling the communication between peer entities at each layer. Traditional protocol state machine implementations use single or multiple threads to represent and execute multiple contexts that represent multiple instances of a protocol state machine. At any time, a myriad of such instances may execute depending on the number of protocol layers and the number of concurrently communicating entities on a given machine.
Each of these instances uses the resources that it needs at any given time, depending on the incoming or outgoing traffic. Therefore, a snapshot over any interval shows frequent use of resources at irregular intervals followed by intervening idle or dormant periods. This does not pose any particular problem on a conventional machine. Such a frequent but irregular use of resources, however, can cause a significant drain of energy on a new class of devices such as handheld computers, wireless devices, or embedded devices. Power is a critical resource on such devices. Each time that a timer goes off or memory is accessed, additional energy consumption is required. In addition, frequent cycles of dormant versus active states at irregular intervals interfere with the power management schemes used on such devices that attempt to conserve energy by “turning down” unused resources during idle times. As such, an alternate method of implementing protocol state machines that will conserve energy on energy conscious devices is necessary. That is, an incremental method of distributing energy usage away from disruptive and irregular patterns to a more predictable and cooperative pattern that can be exploited to reduce overall energy usage would prove advantageous.